#ifndef TOOL_H_
#define TOOL_H_

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>

#define RANGE 10000

// 输出长度为length的数组
void printArray(int * array,int length){
    for(int index = 0;index < length;++index){
        printf("%d. ",array[index]);
    }
    printf("\n");
}
// 随机生成一个长度为length的int类型的数组[0,1000)
int * arrGen(int number,int * initValue){

    srand(time(NULL));
    int * arr = (int *)malloc(sizeof(int) * number);
    if(NULL == arr){
        printf("malloc memory failed.\n");
        return NULL;
    }
    for(int index = 0;index < number;++index){

        if(NULL == initValue) arr[index] = rand()%RANGE;
        else arr[index] = *initValue;
    }
    return arr;
}

void swap(int * a,int * b){

    int tmp = *a;
    *a = *b;
    *b = tmp;
}

#endif //!TOOL_H_